#ifndef MATH_VECTOR_H
#define MATH_VECTOR_H

#include "Point.h"

namespace Math
{
	//A vector is the same as a point, with a few exceptions
	class Vector: public Point
	{
		public:
				//Default cosntructor
				explicit Vector(float x=0.0f,float y=0.0f, float z=0.0f);
				//Copy constructor
				Vector(const Vector& v);

				//Point constructor
				Vector(const Point& p1, const Point& p2);

				static const Vector& X;
				static const Vector& Y;
				static const Vector& Z;
				static const Vector& ORIGIN;

				/**********
				* GETTERS *
				**********/
				float length();
				float magnitude();
				Vector unit();

				/*************
				* OPERATIONS *
				*************/
				void normalize();

				/************
				* OPERATORS *
				************/

				/** Provide a + operator to support vector addition
				* Various syntactic elements and their benefits are explained in this tutorial:
				* http://www.cs.duke.edu/csed/tapestry/howtoe.pdf
				*/
				const Vector& operator+= (const Vector& v)
				{
					_x+=v.x();
					_y+=v.y();
					_z+=v.z();

					return *this;
				}

				friend Point operator+ (const Point& p, const Vector& v)
				{
					Point result(p);

					result+=v;

					return result;
				}

				/** Scalar multiplication and assignment */
				const Vector& operator*= (const float& scalar)
				{
					_x*=scalar;
					_y*=scalar;
					_z*=scalar;

					return *this;
				}

				/** Scalar subtraction and assignment */
				const Vector& operator-= (const float& scalar)
				{
					_x-=scalar;
					_y-=scalar;
					_z-=scalar;

					return *this;
				}

				/** Scalar multiplication */
				friend Vector operator* (const float& scalar, const Vector& v)
				{
					Vector result(v);

					return result*=scalar;
				}

				/** Scalar multiplication */
				friend Vector operator* (const Vector& v,const float& scalar)
				{
					Vector result(v);

					return result*=scalar;
				}


				/** Scalar subtraction */
				friend Vector operator- (const Vector& v, const float& scalar)
				{
					Vector result(v);

					return result-=scalar;
				}
	};
}

#endif
